In [1]:
# This changes the current directory to the base saga directory - make sure to run this first!
# This is necessary to be able to import the py files and use the right directories,
# while keeping all the notebooks in their own directory.
import os
import sys
from astropy import coordinates

if 'saga_base_dir' not in locals():
    saga_base_dir = os.path.abspath('..')
if saga_base_dir not in sys.path:
    os.chdir(saga_base_dir)

In [2]:
import targeting
from masterlist import masterlist
reload(masterlist)


Out[2]:
<module 'masterlist.masterlist' from 'masterlist/masterlist.pyc'>

In [5]:
outfn=None#'newmasterlist_wrisaedit.csv'
mainvars = masterlist.main(outfn, catalogdir='masterlist')

print mainvars.keys()
locals().update(mainvars) # this brings everything in `mainvars` into the notebook's namespace


Loading LEDA catalog...
Loading 2MRS catalog...
Loading EDD catalog...
Loading KK nearby catalog...
Loading 6dF...
Loading 2MASS XSC...
Generating initial catalog from EDD...
Adding NSA...
Simplifying master catalog...
Adding 6df to master catalog...
Filtering master catalog...
Removing objects in master remove list
Using master remove list from the google spreadsheet
Remove list removed 20 objects
Supplementing with 2MASS XSC K mags
['mastercat0nonsa', 'mastercat0', 'join', 'eddcats', 'edd', 'mastercat', 'nsa', 'quiet', 'leda', 'mastercatprerem', 'mastercat1', 'mastercat2', 'twomassxsc', 'sixdf', 'print', 'twomass', 'uploadtogoogle', 'catalogdir', 'outfn', 'exists', 'kknearby']

In [4]:
res = masterlist.remove_from_list(mastercatprerem, 'master')

In [7]:
import requests

In [10]:
print requests.get(masterlist.REMOVE_LIST_URLS['master']).content


REMOVE FROM MASTER LIST,,,,
NSAID,RA,DEC,Comments,remover
35201,213.31632,-3.2058551,repeat of 35200,
100619,165.80822,27.969564,repeat of 138642,
129431,21.138868,3.8006638,repeat of 154180,
88140,159.05657,37.32378, repeat of 158541,
69355,231.52562,41.670647,repeat of 69272,
142519,193.76957,8.0662888,repeat of 162580,
144265,210.19707,59.324124, repeat of 164374,
155970,84.272139,-5.6826266,junk,
88792,174.93583,31.931179,repeat of 14004,
164129,208.03188,-6.057814,repeat of 143975,
135851,140.45622,64.26147,repeat of 76844,
135665,136.43463,25.4368,repeat of 135667,
158972,163.67572,54.30999,repeat of 138326,
164129,208.03188,-6.05781,repeat of 143975,
23271,32.37709,-9.67482,repeat of 131310,
136043,145.726,31.845844,repeat of 136043,RW
88140,159.068,37.3247,repeat of 158541,RW
34815,169.836,57.7585,repeeat of 139161,RW
142519,193.77,8.06629, duplicate of 162580 (actually a satellite embedded),RW
140895,182.971,24.1251,"offcenter, likely duplicate",RW
78244,204.374,8.858,duplicate of 78246,RW
78246,204.397,8.87079,"offcenter, likely duplicate",RW
145840,226.799,1.53397,"offcenter, likely duplicate",

In [44]:
s1=set(mastercatprerem['NSAID']).difference(mastercat['NSAID'])

In [74]:
mastercat = masterlist.filter_catalog(mastercat2, vcut=4000*u.km/u.s)
print len(mastercat)
res=masterlist.x_match_tests(mastercat, basedir='masterlist')


18182
RC3 non-matches: 16222 of 23011
RC3 with v non-matches: 6948 of 10663
ATLAS3D E non-matches: 1 of 260
ATLAS3D Spiral non-matches: 1 of 611
NSA Hosts non-matches: 10 of 67
6dF non-matches: 100587 of 105335
ZCAT non-matches: 49200 of 57536

Various Info


In [67]:
inedd = ~mastercat0['Dist_edd'].mask
inkk = ~mastercat0['Dist_kk'].mask
sum(inedd), sum(inkk), sum(inedd&inkk)


Out[67]:
(3652, 885, 463)

In [111]:
meths = list(np.unique(kknearby['Meth']))
meths = dict(zip(meths, range(len(meths))))
plt.scatter(kknearby['Dist'], [meths[m] for m in kknearby['Meth']],lw=0,alpha=.1)
plt.yticks(meths.values(), meths.keys());
plt.xlim(0,50)


Out[111]:
(0, 50)

In [112]:
sos = list(np.unique(edd['So']))
sos = dict(zip(sos, range(len(sos))))
plt.scatter(edd['Dist'], [sos[m] for m in edd['So']],lw=0,alpha=.1)
plt.yticks(sos.values(), sos.keys());
plt.xlim(0,50)


Out[112]:
(0, 50)

Inspect duplicate PGC#s from close-pairs in NSA


In [53]:
from sys import stdout

ntotswpgc, npgcs, ndups = [], [], []
matchtols = [1,3,5,10,15,20,25,30,40,50,60,120,180]*u.arcsec
for matchtol in matchtols:
    print 'on matchtol',matchtol
    stdout.flush()
    tempcat = masterlist.add_nsa(mastercat0nonsa, nsa=None, removeduplicatepgcson=None, matchtolerance=matchtol)
    ntotswpgc.append(np.sum(tempcat['pgc']>0))
    npgcs.append(len(np.unique(tempcat['pgc']))-1)
    ndups.append(ntotswpgc[-1]-npgcs[-1])


on matchtol 1 arcsec
on matchtol 3 arcsec
on matchtol 5 arcsec
on matchtol 10 arcsec
on matchtol 15 arcsec
on matchtol 20 arcsec
on matchtol 25 arcsec
on matchtol 30 arcsec
on matchtol 40 arcsec
on matchtol 50 arcsec
on matchtol 60 arcsec
on matchtol 120 arcsec
on matchtol 180 arcsec

In [71]:
plt.semilogy(matchtols.value, [.1 if v==0 else v for v in ndups],'o-b')
plt.semilogy(matchtols.value, ntotswpgc,'o-r')
plt.xlabel('asec');
#plt.xlim(0,60)
ndups


Out[71]:
[0, 13, 106, 212, 251, 336, 467, 619, 963, 1337, 1838, 6037, 10599]

In [30]:
testcat = masterlist.add_nsa(mastercat0nonsa, removeduplicatepgcson=None, matchtolerance=60*u.arcsec)
pgc = testcat['pgc'].copy()
pgc[pgc<0]=0
print 'NDUPS=',np.sum(pgc>0)-len(np.unique(pgc)-1)
np.sum(pgc>0),len(np.unique(pgc)-1)


NDUPS= 1837
Out[30]:
(108811, 106974)

In [31]:
#show the duplicates and various bits of possibly useful information
ras, decs, pgcs, dds, nsas, magrs = [], [], [], [], [],[]
multipgcs = np.where(np.bincount(pgc) > 1)[0]
for i,n in enumerate(multipgcs):
    if i%50==0:
        print 'on',i,'of',len(multipgcs)
    if n!=0:
        subcat = testcat[pgc==n]
        for row in subcat[np.argsort(subcat['pgc_match_dist_asec'])]:
            ras.append(row['RA'])
            decs.append(row['DEC'])
            pgcs.append(n)
            dds.append(row['pgc_match_dist_asec'])
            magrs.append(row['ABSMAG_r'])
            nsas.append(row['NSAID'])
res = targeting.sampled_imagelist(ras,decs,len(ras),['PGC#{1}:NSA#{2}:d={0:.2f}:r={3:.1f}'.format(ddi, pgci, nsai, magri) for 
                                                     ddi,pgci,nsai,magri in zip(dds,pgcs,nsas,magrs)])


on 0 of 1718
on 50 of 1718
on 100 of 1718
on 150 of 1718
on 200 of 1718
on 250 of 1718
on 300 of 1718
on 350 of 1718
on 400 of 1718
on 450 of 1718
on 500 of 1718
on 550 of 1718
on 600 of 1718
on 650 of 1718
on 700 of 1718
on 750 of 1718
on 800 of 1718
on 850 of 1718
on 900 of 1718
on 950 of 1718
on 1000 of 1718
on 1050 of 1718
on 1100 of 1718
on 1150 of 1718
on 1200 of 1718
on 1250 of 1718
on 1300 of 1718
on 1350 of 1718
on 1400 of 1718
on 1450 of 1718
on 1500 of 1718
on 1550 of 1718
on 1600 of 1718
on 1650 of 1718
on 1700 of 1718

Check SDSS cross-iding


In [292]:
#note that this may need to be run a few times to get it to actually work
reload(masterlist)
res = masterlist.cross_id_w_sdss(mastercat, chunk=1000, nretrychunk=2, qryfields=['objid', 'ra', 'dec', 'type','up_ra', 'up_dec'])


On chunk starting with 0 of 18182
On chunk starting with 1000 of 18182
On chunk starting with 2000 of 18182
On chunk starting with 3000 of 18182
On chunk starting with 4000 of 18182
On chunk starting with 5000 of 18182
On chunk starting with 6000 of 18182
On chunk starting with 7000 of 18182
On chunk starting with 8000 of 18182
On chunk starting with 9000 of 18182
On chunk starting with 10000 of 18182
On chunk starting with 11000 of 18182
On chunk starting with 12000 of 18182
On chunk starting with 13000 of 18182
On chunk starting with 14000 of 18182
On chunk starting with 15000 of 18182
On chunk starting with 16000 of 18182
On chunk starting with 17000 of 18182
On chunk starting with 18000 of 18182

In [293]:
matched_mastercat = mastercat[res['mastercat_idx']]

In [343]:
msk = res['type']=='STAR'
msk = msk & ~matched_mastercat['r'].mask  # only NSA objects
print np.sum(msk)
targeting.sampled_imagelist(res[msk], None, 100, names=matched_mastercat['NSAID'][msk]);


919

Close pairs


In [347]:
mastercatcoo = coo.ICRS(mastercat['RA'].view(np.ndarray)*u.deg, mastercat['Dec'].view(np.ndarray)*u.deg)
idx, d2d, d3d = mastercatcoo.match_to_catalog_sky(mastercatcoo, 2)

In [433]:
plt.hist(d2d.arcsec,bins=np.linspace(0,60, 100),histtype='step');



In [369]:
msk = (d2d.arcmin>)&(d2d.arcmin<3)&(~mastercat['RA'].mask)&(~mastercat['Dec'].mask)
targeting.sampled_imagelist(mastercat[msk]['RA'],mastercat[msk]['Dec'],200);

In [387]:
#close pairs *and* type=star
matchedd2d = d2d[res['mastercat_idx']]
matchedidx = idx[res['mastercat_idx']]
msk = (res['type']=='STAR')&(matchedd2d.arcmin>3)
print np.sum(msk)
targeting.sampled_imagelist(matched_mastercat[msk]['RA'],matched_mastercat[msk]['Dec'],25,names=matched_mastercat['NSAID'][msk]);


816

In [445]:
#close pairs *and* type=star
matchedd2d = d2d[res['mastercat_idx']]
matchedidx = idx[res['mastercat_idx']]
msk = (res['type']=='STAR')&(matchedd2d.arcmin>0.5)&(matchedd2d.arcmin<1)
print 'N=',np.sum(msk)

print 'name ra dec'
i=0
for row1, row2 in zip(matched_mastercat[msk], mastercat[matchedidx[msk]]):
    print row1['NSAID'], row1['RA'],row1['Dec']
    print '+'+str(row2['NSAID']), row2['RA'],row2['Dec']
    i += 1
    if i>50:
        break


N= 30
name ra dec
52215 171.366547954 57.711714771
+159800 171.361842511 57.721178527
79907 234.402105694 5.95877826687
+-- 234.4008 5.97361
86657 190.52115013 32.5527960482
+-- 190.53285 32.54239
86724 200.488917191 38.7435516098
+86723 200.485275096 38.7345606779
89392 186.462157544 33.5527884499
+89394 186.453617242 33.5468664501
111921 168.353478377 22.1547226441
+-- 168.36705 22.1527
127131 7.90547228512 9.1600849359
+-- 7.89465 9.171
130622 28.2834464806 20.6665057585
+154646 28.2935543184 20.6722318859
138778 166.831288605 61.524695929
+-- 166.8117 61.5295
143311 199.958941946 13.8086897672
+-- 199.9707 13.80666
145547 221.196531684 55.5831127398
+-- 221.18445 55.58888
145688 223.561352051 30.2002485271
+145686 223.550659365 30.210103833
157903 152.586890374 62.9071425873
+-- 152.5671 62.91376
163088 197.47521714 17.1647349943
+163089 197.48335329 17.1678921666
163089 197.48335329 17.1678921666
+163088 197.47521714 17.1647349943
76844 140.439601968 64.2572273039
+135851 140.456217794 64.2614681624
138762 166.728220956 51.2035632325
+32415 166.712289547 51.196153466
-- 168.36705 22.1527
+111921 168.353478377 22.1547226441
142688 194.758059097 34.8604930872
+88637 194.751294673 34.8451837202
-- 196.6038 67.70693
+142981 196.575150664 67.7036686385
143136 198.322472786 36.2172554443
+90692 198.326922772 36.2029375597
164610 212.553733105 -2.57584456675
+164611 212.556105344 -2.56509222086
-- 334.032 22.9423
+168324 334.034716542 22.9341046605
-- 170.5686 20.8756
+139270 170.567842371 20.8658822165
-- 7.89465 9.171
+127131 7.90547228512 9.1600849359
-- 166.8117 61.5295
+138778 166.831288605 61.524695929
-- 132.8916 30.87528
+135527 132.88727516 30.8653413205
-- 303.54945 -11.76026
+148569 303.557635158 -11.7651508488
-- 199.0644 -20.71021
+-- 199.07505 -20.69862
-- 184.5012 8.16528
+141081 184.49023733 8.16619137622

Check things in the 2MASS XSC that aren't in the masterlist


In [18]:
twomassbright = twomassxsc[twomassxsc['k_m_ext'] < 11.75]
tmcoo = coordinates.ICRS(np.array(twomassbright['ra'])*u.deg, np.array(twomassbright['dec'])*u.deg)
macoo = coordinates.ICRS(np.array(mastercat['RA'])*u.deg, np.array(mastercat['Dec'])*u.deg)

In [19]:
idxtm, d2dtm, d3dtm = tmcoo.match_to_catalog_sky(macoo)
idxmt, d2dmt, d3dmt = macoo.match_to_catalog_sky(tmcoo)

In [20]:
np.sum(d2dtm < 10*u.arcsec)/len(idxtm)


Out[20]:
0.091245295369006704

In [21]:
tmcoo[d2dtm>10*u.arcsec]


Out[21]:
<ICRS RA=[ 195.613602  126.279037  180.716919 ...,  339.229462  324.027832
  205.788559] deg, Dec=[-32.542736 -55.289421  26.252848 ..., -37.214504   7.939496  30.338984] deg>

In [22]:
msk = d2dtm>10*u.arcsec
targeting.sampled_imagelist(tmcoo[msk], None, 100, names=twomassbright[msk]['k_m_ext'])


Out[22]:
'name ra dec\n11.678 202.857117 -30.429188\n11.549 16.130062 -45.54565\n10.611 337.993195 -15.440041\n11.221 175.66423 24.822731\n11.24 75.211052 -38.654697\n10.853 60.775616 -53.313438\n11.665 142.473175 -12.629913\n10.602 152.753082 -67.144386\n11.326 51.378147 1.861585\n11.627 74.984795 -64.377281\n10.977 345.991333 27.3022\n9.931 311.953217 -9.995925\n11.227 216.633026 21.557077\n10.464 29.244684 6.03674\n9.142 116.11721 -20.142117\n11.309 243.177841 29.901257\n11.071 36.396862 26.743326\n5.817 261.199646 -34.154469\n10.586 261.28772 37.759892\n11.412 228.899628 69.315758\n10.223 44.144299 48.690365\n11.625 100.57399 14.972238\n10.902 67.390717 24.227404\n10.656 255.713989 -52.785454\n11.237 264.43042 46.385365\n11.748 225.454315 -33.976536\n10.923 197.312164 8.531618\n9.089 284.02356 7.96244\n11.522 277.449585 47.185162\n10.389 258.603333 -23.229786\n9.515 92.195335 32.484249\n11.299 328.122162 12.411445\n11.437 86.372833 -27.770151\n11.562 90.804741 11.452379\n9.291 131.340347 -42.312836\n11.598 93.760094 51.080475\n11.04 137.547409 23.121586\n11.287 77.263069 -37.825932\n11.207 227.640762 -43.551579\n10.883 168.600159 -3.893193\n9.744 23.002945 -85.177689\n11.265 226.507812 8.789887\n10.509 306.504761 -18.504353\n11.511 0.399345 -27.576555\n11.166 129.243713 55.645657\n11.004 70.624771 -44.201004\n11.127 173.294006 -10.228884\n10.724 181.131439 -17.487543\n10.994 181.578629 -28.197113\n10.093 61.077057 29.689796\n10.983 32.483013 75.337288\n11.472 173.878845 -25.145077\n11.71 94.477226 -43.664051\n8.678 254.902847 -40.05698\n10.183 332.364349 40.989735\n9.942 216.086472 36.461395\n11.536 81.907433 -67.458473\n11.7 193.821579 -22.854176\n9.374 29.425783 35.916149\n10.819 226.208389 -20.324736\n11.153 217.298569 -71.289436\n9.884 28.165037 36.171463\n11.242 108.925804 -1.878873\n11.009 195.321213 53.860844\n10.836 110.831993 -16.311054\n11.214 210.33049 -15.761476\n11.681 353.380402 24.020041\n10.135 39.191849 2.050425\n11.636 36.120735 -26.3685\n10.588 195.517548 29.253603\n10.625 217.056091 25.947426\n11.675 284.544006 -24.644342\n11.724 136.017212 -19.219843\n11.693 41.266514 36.710148\n11.447 50.294949 -56.185795\n10.866 317.120819 -43.489433\n11.276 140.319504 24.518074\n11.412 56.624069 0.718927\n10.981 97.288338 -13.527681\n11.671 330.057404 -6.979995\n11.536 298.210236 -19.218109\n4.798 272.33374 -25.911867\n11.611 314.152466 -51.561249\n11.224 184.553635 44.173275\n11.55 351.700592 35.226242\n11.739 224.481003 -67.607925\n11.336 27.758255 48.524555\n11.502 183.428207 -57.555382\n11.224 46.207409 41.436199\n11.026 26.416039 -4.680731\n10.85 138.427582 20.569756\n10.679 271.105286 -69.877686\n11.224 341.298553 53.402447\n11.276 54.535854 10.118572\n10.245 319.6474 19.718653\n10.82 174.229065 -32.831539\n9.954 303.023041 -55.245892\n10.965 327.867279 53.277321\n11.475 41.683453 21.227337\n9.591 319.330353 61.908901'

Visual inspection and x-matching w/NED reveals that most have redshifts, but not all, esp. in the South

Check to see consistency with NED's redshift-indep distances


In [11]:
nedd = table.Table.read('masterlist/NED24.8.1-D-9.3.0-20140905.csv', header_start=12, data_start=13)
print(nedd.colnames, len(nedd))


(['Exclusion Code', 'D', 'G', 'Galaxy ID', 'm-M', 'err', 'D (Mpc)', 'Method', 'REFCODE', 'SN ID', 'redshift (z)', 'Hubble const.', 'Adopted LMC modulus', 'Date (Yr. - 1980)', 'Notes'], 97012)

In [12]:
nedd['Galaxy ID']


Out[12]:
<MaskedColumn name='Galaxy ID' unit=None format=None description=None>
masked_array(data = ['SDSS-II SN 13651' 'SDSS-II SN 13651' 'SDSS-II SN 13651' ...,
 'SDSS-II SN 01662' 'SDSS-II SN 01662' 'SDSS-II SN 01662'],
             mask = [False False False ..., False False False],
       fill_value = N/A)

In [ ]: